; (function ($) {
    $.fn.formComponent = function () {
        var selector = $(this).selector;
        var f = {
            self:{},
            validate: function() {
                var success = true;
                this.self.find(".form-control").each(function () {
                var t = $(this);
                if (t.hasAttribute("disable") || t.hasAttribute("disable")) {
                    return;
                }
                if (t.attr("requried") && !v.val()) {
                    t.parents(".form-group").addClass(".has-error");
                    success = false;
                    return;
                }
                return success;
                });
            },

            tojson: function() {
                var arr = this.self.serializeArray();
                var data = {};
                for (var i = 0; i < arr.length; i++) {
                    var item = arr[i];
                    data[item.name] = item.value;
                }
                return data;
            },
            submit: function (url, param, options) {
                var de = {
                    success: function(data) {
                        console.log(data);
                    },
                    error: function(e,s) {
                        console.error(e);
                        console.error(s);
                    }
                }
                var settings = $.extend({}, de, options);
                
                $.ajax({
                    url: url,
                    data: param,
                    type: "POST",
                    success: settings.success,
                    error: settings.error,
                    beforeSend: function() {
                        
                    },
                    complete: function() {
                        
                    }
                });
            }
        };
        f.self = $(this);
        return f;
    };
    
})(jQuery);